package com.hezhou.oauth2.server.service;

import com.hezhou.oauth2.web.entities.SysUser;
import com.hezhou.oauth2.web.service.SysUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * ---------------------------
 * (UserDetailsService) 自定义的用户信息类
 * ---------------------------
 *
 * @Author: [hezhou]
 * @Date: 2020/3/12
 * @Version: [1.0.1]
 * ---------------------------
 */
@Component("customUserDetailsService")
public class CustomUserDetailsService extends AbstractUserDetailsService {

    Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private SysUserService sysUserService;

    @Override
    SysUser findSysUser(String usernameOrMobile){
        logger.info("请求认证的用户名：" + usernameOrMobile);
        return sysUserService.findByUserName(usernameOrMobile);
    }
}
